package com.marlon.springboot.jap.service.impl;

import cn.hutool.core.util.IdUtil;
import com.marlon.springboot.jap.entity.User;
import com.marlon.springboot.jap.mapper.IUserMapper;
import com.marlon.springboot.jap.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author marlon
 * @create 2023-11-18 14:03
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserMapper userMapper;

    @Override
    public List<User> queryAll() {
        return userMapper.findAll();
    }

    @Override
    public User findById(String id) {
        return userMapper.getById(id);
    }

    @Override
    public User save(User user) {
//        user.setId(IdUtil.randomUUID());
        return userMapper.save(user);
    }

    @Override
    public User updateById(User user) {
        return userMapper.save(user);
    }

    @Override
    public void deleteById(String id) {
        userMapper.deleteById(id);
    }
}
